<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
        content="width=device-width, initial-scale=1.0">
<meta name="HandheldFriendly" content="true">
<title>Sample</title>
</head>
<body>
<script>
function getPlaceFromFlickr(lat,lon,callback){
   // 定义YQL语句
   var yql = 'select * from flickr.places where lat=' +
               lat + ' and lon=' + lon;
 
   // 将YQL网络服务的API嵌入到网页，这是JavaScript库
   var url = 'http://query.yahooapis.com/v1/public/yql?q='+
                encodeURIComponent(yql) +
               '&format=json&diagnostics=' +
               'false&callback=' + callback;
 
   // 创建一个script元素，并引用JavaScript库，最后放在head元素中
   var script = document.createElement('script');
   script.setAttribute('src',url);
   document.getElementsByTagName('head')[0].appendChild(script);
};
 
// 回调函数，输出位置地名
function output(o){
   if(typeof(o.query.results.places.place) != 'undefined'){
      alert(o.query.results.places.place.name);
   }
}
getPlaceFromFlickr(22.543099, 114.057868, 'output');
</script>
</body>
</html>